<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const str1 = "name";
      const str2 = () => "age";
      const user = {
        name: "jack",
        age: 20,
        "max age": 40,
      };
      console.log(user[str1]); //user["name"]
      console.log(user[str2()]); //user["age"]
      console.log(user["max age"]);
      console.log(user[prompt("key?")]);
    </script>
  </body>
</html>
